package com.hrserviceserve.dao;

import com.hrserviceserve.entity.Contract;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface ContractRepository extends JpaRepository<Contract,Integer> {
    @Query(value = "select * from contract where " +
            "if(?1!='',personnel_name=?1,1=1)" +
            "and if(?2!='',position=?2,1=1)",nativeQuery = true)
    Page<Contract> findAllWhere(String name,String position, Pageable pageable);

    int deleteByContractId(int id);
}
